package cn.edu.sdjzu.xg11.domain;

import java.io.Serializable;
import java.util.Set;

import cn.edu.sdjzu.xg11.domain.authority.Actor;

public final class Teacher extends Actor implements Comparable<Teacher>,Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Integer nextID = 1;
	private Integer id;
	private String name;
	private Title title;
	private Degree degree;
	private Department department;
	private Set<GraduateProject> projects;
	//初始化块
	{
		this.id = nextID;
		nextID++;
//		System.out.println("N");
	}
	public Teacher() {
		super();
	}


	public Teacher(String name, Title title, Degree degree,
			Department department) {
		super();
		this.name = name;
		this.title = title;
		this.degree = degree;
		this.department = department;
	}
	
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Title getTitle() {
		return title;
	}

	public void setTitle(Title title) {
		this.title = title;
	}

	public Degree getDegree() {
		return degree;
	}

	public void setDegree(Degree degree) {
		this.degree = degree;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public Set<GraduateProject> getProjects() {
		return projects;
	}

	public void setProjects(Set<GraduateProject> projects) {
		this.projects = projects;
	}

	




	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Teacher other = (Teacher) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}


	@Override
	public int compareTo(Teacher o) {
		// TODO Auto-generated method stub
		return this.id-o.getId();
	}


	/**
	 * Constructs a <code>String</code> with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String</code> representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "    ";
	    
	    String retValue = "";
	    
	    retValue = "Teacher ( "
	        + super.toString() + TAB
	        + "id = " + this.id + TAB
	        + "name = " + this.name + TAB
	        + "title = " + this.title + TAB
	        + "degree = " + this.degree + TAB
	        + "department = " + this.department + TAB
	        + "projects = " + this.projects + TAB
	        + " )";
	
	    return retValue;
	}

}
